{template 'common/header'}

<ul class="nav nav-tabs">
	<li><a href="{php echo $this->createWebUrl('house', array('op'=>'display'));}">房源列表</a></li>
	<li {if empty($id)}class="active"{/if}><a href="{php echo $this->createWebUrl('house', array('op'=>'edit'));}">添加房源</a></li>
	{if !empty($id)}
	<li class="active"><a href="{php echo $this->createWebUrl('house', array('op'=>'edit', 'id'=>$id));}">编辑房源</a></li>
	{/if}
</ul>

<div class="main">
	<form action="" method="post" class="form-horizontal form" id="form">
		<div class="panel panel-default">
			<div class="panel-heading">房源</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">出租方式</label>
					<div class="col-xs-12 col-sm-8">
						<label class="radio radio-inline">
							<input type="radio" name="goods[rent_type]" value="0" {if intval($goods['rent_type']) == 0}checked="checked"{/if}> 整套
						</label>
						<label class="radio radio-inline">
							<input type="radio" name="goods[rent_type]" value="1" {if intval($goods['rent_type']) == 1}checked="checked"{/if}> 单间
						</label>
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">小区名称</label>
					<div class="col-xs-12 col-sm-8">
						<input type="text" name="goods[village_name]" class="form-control" value="{$goods['village_name']}" />
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">房屋地址</label>
					<div class="col-xs-12 col-sm-8">
						<input type="text" name="goods[address]" class="form-control" value="{$goods['address']}" />
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">房号</label>
					<div class="col-xs-12 col-sm-4">
						<input style="float:left; width:auto;" type="text" name="goods[building_num]" class="form-control" value="{$goods['building_num']}" /><span style="float:left; margin-left:10px;">栋</span>
						<input style="float:left; width:auto;" type="text" name="goods[house_num]" class="form-control" value="{$goods['house_num']}" /><span style="float:left; margin-left:10px;"">室</span>
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">房屋户型</label>
					<div class="col-xs-12 col-sm-4">
						<input style="float:left; width:auto;" type="text" name="goods[rooms]" class="form-control" value="{$goods['rooms']}" /><span style="float:left; margin-left:10px;">室</span>
						<input style="float:left; width:auto;" type="text" name="goods[hall]" class="form-control" value="{$goods['hall']}" /><span style="float:left; margin-left:10px;"">厅</span>
						<input style="float:left; width:auto;" type="text" name="goods[toilet]" class="form-control" value="{$goods['toilet']}" /><span style="float:left; margin-left:10px;"">卫</span>
						<input style="float:left; width:auto;" type="text" name="goods[area]" class="form-control" value="{$goods['area']}" /><span style="float:left; margin-left:10px;"">平米</span>
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">朝向</label>
					<div class="col-xs-12 col-sm-8">
						<select class="form-control" name="goods[orientations]">
							<option value="">选择朝向</option>
							<option value="东" {if $goods['orientations'] == '东'}selected="selected"{/if} >东</option>
							<option value="西" {if $goods['orientations'] == '西'}selected="selected"{/if} >西</option>
							<option value="南" {if $goods['orientations'] == '南'}selected="selected"{/if} >南</option>
							<option value="北" {if $goods['orientations'] == '北'}selected="selected"{/if} >北</option>
							<option value="东南" {if $goods['orientations'] == '东南'}selected="selected"{/if} >东南</option>
							<option value="西南" {if $goods['orientations'] == '西南'}selected="selected"{/if} >西南</option>
							<option value="东北" {if $goods['orientations'] == '东北'}selected="selected"{/if} >东北</option>
							<option value="西北" {if $goods['orientations'] == '西北'}selected="selected"{/if} >西北</option>
						</select>
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">装修情况</label>
					<div class="col-xs-12 col-sm-8">
						<select class="form-control" name="goods[decoration]">
							<option value="">选择装修情况</option>
							<option value="毛坯" {if $goods['decoration'] == '毛坯'}selected="selected"{/if} >毛坯</option>
							<option value="简单装修" {if $goods['decoration'] == '简单装修'}selected="selected"{/if} >简单装修</option>
							<option value="中等装修" {if $goods['decoration'] == '中等装修'}selected="selected"{/if} >中等装修</option>
							<option value="精装修" {if $goods['decoration'] == '精装修'}selected="selected"{/if} >精装修</option>
							<option value="豪华装修" {if $goods['decoration'] == '豪华装修'}selected="selected"{/if} >豪华装修</option>
						</select>
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">房源描述</label>
					<div class="col-sm-8 col-xs-12">
		                <textarea class="form-control" name="goods[detail]" id="detail" rows="5">{$goods['detail']}</textarea>
					</div>
				</div>
				
				
				
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">房屋图片</label>
					<div class="col-xs-12 col-sm-8">
						{php echo tpl_form_field_image('goods[imgs]', $goods['imgs']);}
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">月租金</label>
					<div class="col-xs-12 col-sm-8">
						<div class="input-group">
							<input type="text" name="goods[rental]" class="form-control" value="{$goods['rental']}" >
							<span class="input-group-addon">元</span>
						</div>
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">付款方式</label>
					<div class="col-xs-12 col-sm-8">
						<select class="form-control" name="goods[pay_cate]">
							<option value="0" {if $goods['pay_cate'] == 0}selected="selected"{/if} >押一付一</option>
							<option value="1" {if $goods['pay_cate'] == 1}selected="selected"{/if} >押一付三</option>
						</select>
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">是否上架</label>
					<div class="col-xs-12 col-sm-8">
						<label class="radio radio-inline">
							<input type="radio" name="goods[sale_status]" value="1" {if intval($goods['sale_status']) == 1}checked="checked"{/if}> 上架
						</label>
						<label class="radio radio-inline">
							<input type="radio" name="goods[sale_status]" value="0" {if intval($goods['sale_status']) == 0}checked="checked"{/if}> 下架
						</label>
					</div>
				</div>
				
				<div class="form-group">
					<div class="col-xs-12 col-sm-9 col-md-10 col-lg-10 col-sm-offset-3 col-md-offset-2 col-lg-offset-2">
						<input type="hidden" name="id" value="{$goods['id']}" />
						<input name="submit" type="submit" value="提交" class="btn btn-primary" />
						<input type="hidden" name="token" value="{$_W['token']}" />
					</div>
				</div>
			</div>
		</div>
	</form>
</div>

<script>
require(['jquery', 'util'], function($, util){
	$(function(){
		util.editor($('#detail')[0]);
		
		$('#form').submit(function(){
			if($('input[name="goods[village_name]"]').val() == ''){
				util.message('请填写小区名称.');
				return false;
			}
			if($('input[name="goods[address]"]').val() == ''){
				util.message('请填写房屋地址.');
				return false;
			}
			if($('input[name="goods[imgs]"]').val() == ''){
				util.message('请上传房屋图片.');
				return false;
			}
			if($('input[name="goods[rental]"]').val() == ''){
				util.message('请填写月租金.');
				return false;
			}
			
			return true;
		});
	});
});
</script>

{template 'common/footer'}